package com.scf.loanmanage.configuration;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

@Configuration
public class RabbitConfiguration {


    @Bean
    public Queue pluginQueue() {
        return new Queue("插件延迟的消息队列");
    }

    @Bean
    public CustomExchange pluginExchange() {
        HashMap<String, Object> map = new HashMap<>();
        //指定交换机

        map.put("x-delayed-type", "direct");
//第二个参数表示是延迟的交换机
        return new CustomExchange("延迟交换机", "x-delayed-message", true, false, map);
    }

    @Bean
    public Binding bindingddelayed(Queue pluginQueue, CustomExchange pluginExchange) {
        //将消息队列绑定交换机
        return BindingBuilder.bind(pluginQueue).to(pluginExchange).with("死的路由").noargs();
    }


}